package com.xueyi.system.seed.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xueyi.system.seed.domain.po.BaseSeedPo;
import com.xueyi.system.seed.domain.query.BaseSeedQuery;
import com.xueyi.system.seed.domain.dto.BaseSeedDto;
import com.xueyi.system.seed.mapper.BaseSeedMapper;
import com.xueyi.system.seed.service.IBaseSeedService;
import com.xueyi.system.seed.manager.IBaseSeedManager;
import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 种子种苗基础管理管理 服务层处理
 *
 * @author zlf
 */
@Service
public class BaseSeedServiceImpl extends BaseServiceImpl<BaseSeedQuery, BaseSeedDto, IBaseSeedManager> implements IBaseSeedService {


    @Autowired
    private BaseSeedMapper baseSeedMapper;

    /**
     * 查询种子种苗基础管理对象列表 | 数据权限 | 附加数据
     *
     * @param seed 种子种苗基础管理对象
     * @return 种子种苗基础管理对象集合
     */
    @Override
    //@DataScope(userAlias = "createBy", mapperScope = {"BaseSeedMapper"})
    public List<BaseSeedDto> selectListScope(BaseSeedQuery seed) {
        return baseManager.selectListExtra(seed);
    }

    @Override
    public List<BaseSeedPo> getCode(String batch) {
        QueryWrapper<BaseSeedPo> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("batch",batch);
        queryWrapper.orderByDesc("create_time");
        List<BaseSeedPo> seedPoList = baseSeedMapper.selectList(queryWrapper);
        return seedPoList;
    }
}
